package com.chinatelecom.telecollege.sellerrewarding.service;

import com.chinatelecom.telecollege.sellerrewarding.Entity.area;
import com.chinatelecom.telecollege.sellerrewarding.repository.areaRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * Created by lenovo on 2017/6/21.
 */
@Service
public class areaService {
    @Autowired
    private areaRepo areaRepo;

    @Transactional
    public List<area> findAll() {
        return areaRepo.findAll();
    }
    public area find(int id) {
        return areaRepo.findOne(id);
    }
    public area find(String name) {
        return areaRepo.findByname(name);
    }
    public void save(String name) {
        area area = new area();
        area.setName(name);
        areaRepo.save(area);
    }
    public void save(int id,String name) {
        area area = find(id);
        area.setName(name);
        areaRepo.save(area);
    }
    public void delete(int id) {
        areaRepo.delete(id);
    }
}
